openapi: 3.0.0
info:
  title: Кальулятор инвестиций
  version: 0.0.1
servers:
  - url: http://localhost:8080/api/v1
    description:  prod server
paths: 
  /calc:
    post:
        summary: Метод вычисления нужного параметра
        requestBody:
            required: true
            content:
                application/json: 
                    schema: 
                      
                        $ref: "#/components/schemas/Calc"

            

        responses: 
            200:
                description: Успешно
                content: 
                    application/json: 
                        schema: 
                            $ref: "#/components/schemas/ResponseOk"
            400:
                description: Неверные данные, ошибка валидации.
                content: 
                    application/json: 
                        schema: 
                            $ref: "#/components/schemas/ResponseError"
           

components:
    schemas:
        Calc:
            type: object
            required:
                - toCalculate
            properties:
                toCalculate:
                    type: string 
                    example: "TARGET"
                    enum:
                        - TARGET
                        - START_UP_CAPITAL
                        - INVEST_PERIOD
                        - COEFFICIENT
                        - ADDICTIONAL_INVESTMENT
                target:
                    type: string 
                    example: "1000000000.00"
                startUpCapital:
                    type: string 
                    example: "10000423.43"
                investPeriod:
                    type: object 
                    properties: 
                      amount:
                        type: integer 
                        example: 1
                      period:
                        type: string 
                        example: MONTHS
                        enum:
                            - MONTHS
                            - YEARS
                coefficient: 
                    type: string 
                    example: "10,83"
                reinvestPeriod:
                    type: string 
                    example: QUARTERLY
                    enum:
                        - NEVER
                        - QUARTERLY
                        - TWICE_A_YEAR
                        - MONTHLY
                        - YEARLY
                
        ResponseOk:
            type: object
            required:
                - success
            properties:
                success:
                    type: boolean
                    example: true
                result:
                    type: string
                    example: "10000.32"
                    description: Найденный параметр.
        ResponseError:
            type: object
            required:
                - success
            properties:
                success:
                    type: boolean
                    example: true
                error:
                    type: string
                    example: "failed to decode request"
